﻿using System;
using System.Text;

namespace SwissTransTracker
{
    /// <summary>
    ///     See transport.opendata.ch
    /// </summary>
    public class Checkpoint
    {
        /// <summary>
        ///     The location of the checkpoint
        /// </summary>
        public Location Station { get; set; }

        /// <summary>
        ///     The arrival time to the checkpoint
        /// </summary>
        public DateTime? Arrival { get; set; }

        /// <summary>
        ///     The departure time from the checkpoint
        /// </summary>
        public DateTime? Departure { get; set; }

        /// <summary>
        ///     The arrival/departure platform
        /// </summary>
        public int? Platform { get; set; }

        /// <summary>
        ///     The checkpoint prognosis
        /// </summary>
        public Prognosis Prognosis { get; set; }

        public override string ToString()
        {
            var sb = new StringBuilder();
            var nl = Environment.NewLine;
            if(this.Station != null)
            {
                sb.AppendFormat("Station: {0}\t{1}", nl, this.Station.ToString().Replace(nl, nl + '\t'));
            }
            if (this.Platform != null)
            {
                sb.AppendFormat("Platform: {0}{1}", this.Platform, nl);
            }
            if (this.Arrival != null) sb.AppendFormat("Arrival: {0}{1}", this.Arrival, nl);
            if (this.Departure != null) sb.AppendFormat("Departure: {0}{1}", this.Departure, nl);
            if (this.Prognosis != null)
                sb.AppendFormat("Prognosis: {0}\t{1}", nl, this.Prognosis.ToString().Replace(nl, nl + '\t'));
            return sb.ToString();
        }
    }
}